//
//  HLEExpandButton.m
//  YsToolsManager
//
//  Created by hle1 on 2021/10/26.
//

#import "HLEExpandButton.h"
#import <YYCategories/YYCategories.h>
@implementation HLEExpandButton

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
{
    if (self.expand == 0) {
        return  [super pointInside:point withEvent:event];
    }else{
        BOOL result = [super pointInside:point withEvent:event];
        if (result) {
            return result;
        }
        return [self pointCheck:point view:self spacing:self.expand];
    }
}

- (BOOL)pointCheck:(CGPoint)p view:(UIView *)v spacing:(NSInteger)spacing {
    CGFloat minX = -(spacing);
    CGFloat minY = -(spacing);
    CGFloat maxX = v.width + spacing;
    CGFloat maxY = v.height + spacing;
    return (p.x >= minX) && (p.x <= maxX) && (p.y >= minY) && (p.y <= maxY);
}

@end
